<?
    include "../common.php" ;
    $opt = $_POST['opt'] ;
    if( $opt == 'selTel' ){
        $tel = $_POST['tel'] ;
        $sql = "SELECT * FROM `users` WHERE tel = {$tel}" ;
        $res = mysqli_query($link,$sql);
        if( mysqli_affected_rows($link) ){
            $arr['status'] = 1 ; 
            $arr['info'] = '手机号存在！' ;
        } else {
            $arr['status'] = 0 ; 
            $arr['info'] = '可用手机号！' ;
        }
    }
    if( $opt == 'register' ){
        $tel = $_POST['tel'] ;
        $pwd = $_POST['pwd'] ; 
        $sql = "INSERT INTO `users` (pwd,tel,ulevel) VALUES ('{$pwd}','{$tel}',3)" ;
        $res = mysqli_query($link,$sql);
        if( $res ){
            $arr['status'] = 1 ;
            $arr['info'] = '注册成功!' ;
        } else {
            $arr['status'] = 0 ;
            $arr['info'] = '操作失败!' ; 
        }
    }
    echo json_encode($arr);
?>